package com.linfeng.component.tools;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MqTools {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Value(value = "${rocketmq.default_topic: default_topic}")
    private String defaultTopic;

    public void send(String topic, Object message) {

        rocketMQTemplate.convertAndSend(topic, message);
    }

    public void send(Object message) {

        send(defaultTopic, message);
    }
}
